﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>消息中心</title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/message.css"/>
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <link href="/peopleList/css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="/peopleList/js/jquery-3.3.1.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>

</head>
<script>
    $(function () {
        /**
         * 查出所有评论
         */
        $.get("/users/beFriendshipComments",function (data) {
            console.log(data);
            var list={list:data}
            $("#total").renderValues(list,{
                getImg:function (item,value) {
                    if (value) {
                        $(item).attr("src",value[0]);
                    }
                },
                getHref:function (item,value) {
                    if (value) {
                        var json=JSON.parse(value);
                        var href=$(item).data("href")
                        $(item).attr("data-href",href+json.friendshipId+"&state=list");
                        $(item).attr("data-sid",json.userCommentId);
                    }

                }
            })


            $(".userComment").click(function () {
                console.log(1);
                var href=$(this).data("href")
                var sid=$(this).data("sid")
                $.ajax({
                    type: "put",
                    url: '/users/beFriendshipComments',
                    data:{friendshipCommentId:sid},
                    success: function (data) {
                        location.href=href;
                    }
                })
            })
        })

        /**
         * 查出所有回复
         */
        $.get("/users/beFirendshipReplies",function (data) {
            console.log(data);
            var list={list:data}
            $("#reply").renderValues(list,{
                getImg:function (item,value) {
                    if (value) {
                        $(item).attr("src",value[0]);
                    }
                },
                getHref:function (item,value) {
                    console.log(value);
                    if (value) {
                        var json =JSON.parse(value);
                        var href=$(item).data("href")
                        $(item).attr("data-href",href+json.friendshipId+"&state=list");
                        $(item).attr("data-sid",json.id);
                    }

                }
            })

            $(".userComment").click(function () {
                console.log(1);
                var href=$(this).data("href")
                var sid=$(this).data("sid")
                $.ajax({
                    type: "put",
                    url: '/users/beFriendshipReply',
                    data:{friendshipReplyId:sid},
                    success: function (data) {
                        location.href=href;
                    }
                })
            })
        })




    })
</script>
<body>


<section class="aui-flexView">
    <header class="aui-navBar aui-navBar-fixed">
        <a href="commentMessage.html">
            <i class="icon icon-return"></i>
        </a>
        <div class="aui-center">
            <span class="aui-center-title">好友列表</span>
        </div>
        <a href="javascript:;" class="aui-navBar-item">
            <i class="icon icon-more"></i>
        </a>
    </header>
    <section class="aui-scrollView">
        <div class="aui-tab" data-ydui-tab >
            <div id="total">
                <div id="comment" render-loop="list">
                    <div class="tab-panel"  >
                        <div class="tab-panel-item tab-active" >
                            <a role="button" class="aui-flex b-line total userComment" render-key="list.json"
                               render-fun="getHref" data-href="/mine/friendshipComment.html?id=">
                                <span style="display: none" ></span>
                                <!--头像-->
                                <div class="aui-look-img">
                                    <img render-src="list.user.headImgUrl">
                                </div>
                                <div class="aui-flex-box">
                                    <h3 render-html="list.user.nickName" style="color: #732D2D"></h3>
                                    <p render-html="list.content" ></p>
                                    <span render-html="list.createTime"></span>
                                </div>
                                <div>
                                    <img style="width: 90px" render-key="list.friendship.imgArr" render-fun="getImg">
                                </div>
                                <span class="badge badge-danger badge-pill" ></span>
                            </a>
                        </div>
                    </div>
                </div>
            </div>

            <div id="reply">
                <div  render-loop="list">
                    <div class="tab-panel" >
                        <div class="tab-panel-item tab-active" >
                            <a role="button" class="aui-flex b-line total userComment" render-key="list.json"
                               render-fun="getHref" data-href="/mine/friendshipComment.html?id=">
                                <span style="display: none" ></span>
                                <!--头像-->
                                <div class="aui-look-img">
                                    <img render-src="list.user.headImgUrl">
                                </div>
                                <div class="aui-flex-box">
                                    <h3 render-html="list.user.nickName" style="color: #732D2D"></h3>
                                    <p render-html="list.content" ></p>
                                    <span render-html="list.createTime"></span>
                                </div>
                                <div>
                                    <img style="width: 90px" render-key="list.friendship.imgArr" render-fun="getImg">
                                </div>
                                <span class="badge badge-danger badge-pill" ></span>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</section>

<script>
    $(function () {

    })
</script>
</body>
</html>